//By Store:提交的新促销为非SuperMarket的店号，且其生效区间与系统中的45 Trait或相同店号有重叠，同时新零售价格较高时，
//错误提示：单店AR/TR大于等于系统相同时间段的AR/TR/BP/SB

//By Store:提交的新促销为非SuperMarket的店号，且其生效区间与系统中的45 Trait或相同店号相同，同时两者价格相等时，
//错误提示：单店AR/TR大于等于系统相同时间段的AR/TR/BP/SB
var result_6566 = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"", "MSG":"","DATA":""}');
//var JSON_CSRL_LIST = JSON.parse(find_Item_inCSRL(ITEM_NBR, CSRL));

function getRetailList(TRAIT_STORE_NBR, NEW_RETAIL, LIST, NEW_RETAIL_EFF_DATE, NEW_RETAIL_EXP_DATE) {
  for (var i = 0; i < LIST.length; i++) {
    if (LIST[i].PRICE_TYPE != 'CS'
      && (LIST[i].PRICE_TRAIT == 45 || LIST[i].PRICE_TRAIT == TRAIT_STORE_NBR)) {
      if (isDateIntersection(NEW_RETAIL_EFF_DATE, NEW_RETAIL_EXP_DATE, LIST[i].EFFECTIVE_DATE, LIST[i].EXPIRATION_DATE)
        && NEW_RETAIL > LIST[i].CUST_BASE_RTL_AMT) {
        return 1;
      } else if (betweenDay(NEW_RETAIL_EFF_DATE, new Date(NEW_RETAIL_EXP_DATE, LIST[i].EFFECTIVE_DATE)) == 0
        && betweenDay(NEW_RETAIL_EXP_DATE, new Date(NEW_RETAIL_EXP_DATE, LIST[i].EXPIRATION_DATE)) == 0
        && NEW_RETAIL == LIST[i].CUST_BASE_RTL_AMT) {
        return 2;
      }
    }
      return 3;
  }
};

if (TRAIT_STORE_FLAG == "S"
  && isARTR(RETAIL_TYPE)
  && !isSupermarketTrait(TRAIT_STORE_NBR)
  && !isNull(JSON_CSRL_LIST)) {
  if (getRetailList(TRAIT_STORE_NBR, NEW_RETAIL, JSON_CSRL_LIST, NEW_RETAIL_EFF_DATE, NEW_RETAIL_EXP_DATE) != 3) {
    result_6566.CODE = 2;
    result_6566.ACTION = "CHECKING_REPORT";
    result_6566.MSG = "单店AR/TR大于等于系统相同时间段的AR/TR/BP/SB";
  }
}
JSON.stringify(result_6566);

